<?php
// +----------------------------------------------------------------------
// | UCToo [ Universal Convergence Technology ]
// +----------------------------------------------------------------------
// | Copyright (c) 2014-2018 http://uctoo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Patrick <contact@uctoo.com>
// +----------------------------------------------------------------------
/**
 *	easywechat 缓存适配成TP5缓存
 *
 */
namespace uctoo;
use Psr\SimpleCache\CacheInterface;
use think\Cache;

class MyCustomCache implements CacheInterface
{
    public function get($key, $default = null)
    {
        // your code
        return cache($key);
    }

    public function set($key, $value, $ttl = null)
    {
        // your code
        return cache($key,$value,$ttl);
    }

    public function delete($key)
    {
        // your code
        return cache($key,null);
    }

    public function clear()
    {
        // your code
        return cache(null);
    }

    public function getMultiple($keys, $default = null)
    {
        // your code
        $value = [];
        foreach ($keys as $key) {
          $value[$key] = cache($key);
        }
        return $value;
    }

    public function setMultiple($values, $ttl = null)
    {
        // your code
        foreach ($values as $key =>$value ) {
            cache($key,$value,$ttl);
        }
        return true;
    }

    public function deleteMultiple($keys)
    {
        // your code
        foreach ($keys as $key) {
            cache($key,null);
        }
        return true;
    }

    public function has($key)
    {
        // your code
        return Cache::has($key);
    }
}


